<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDiscountSalesRuleTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('discount_sales_rule', function(Blueprint $table)
        {
            //商品促销规则
            $table->increments('id');

            $table->string('name')  ->nullable()->comment('折扣名称');

            $table->timestamp('start_time')     ->nullable()  ->comment('开始时间');
            $table->timestamp('end_time')       ->nullable()  ->comment('结束时间');

            $table->integer('satisfy_number')   ->default(0)  ->comment('享受优惠的起步数量');
            $table->decimal('satisfy_amount')   ->default(0)  ->comment('享受优惠的起步金额');

            $table->integer('free_get_number')  ->default(0)  ->comment('免费赠送的数量');
            $table->integer('goods_id')         ->default(0)  ->comment('赠品的商品id');

            $table->decimal('reduce_amount')    ->default(0)  ->comment('优惠的金额');
            $table->decimal('reduce_rate')      ->default(1)  ->comment('优惠的折扣');

            $table->string('type')              ->nullable()  ->comment('折扣类型:buy_get_free,reduce,discount');
            $table->integer('status')           ->defatlt(0)  ->comment('状态:0未启用，1启用');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
